package org.vaadin.nf4v.core.config;

import com.vaadin.ui.Component;

/**
 * Page configuration.
 * Represents single page in context.
 *
 * Describes two main page parameters:
 * 1. class - to instantiate page instance
 * 2. uti - to uniquely identify page in browser url
 *
 * Both parameters should be unique within context.
 *
 * Note: one page configuration may be shared between few contexts (e.g. login page, error page)
 */
public class PageConfig extends AbstractConfig {
    private Class<? extends Component> pageClass;
    private String uri;
    private boolean homePage = false;

    /**
     * @return true if page is home page for context, false otherwise
     */
    public boolean isHomePage() {
        return homePage;
    }

    /**
     * @param homePage true to mark page as home page
     */
    public void setHomePage(boolean homePage) {
        this.homePage = homePage;
    }

    /**
     * @return page class
     */
    public Class<? extends Component> getPageClass() {
        return pageClass;
    }

    /**
     * Sets page class
     *
     * @param pageClass page class
     */
    public void setPageClass(Class<? extends Component> pageClass) {
        this.pageClass = pageClass;
    }

    /**
     * @return page uri
     */
    public String getUri() {
        return uri;
    }

    /**
     * Sets page uri
     *
     * @param uri page uri
     */
    public void setUri(String uri) {
        this.uri = uri;
    }

    @Override
    public String toString() {
        return "PageConfig{" +
                "isHomePage=" + homePage +
                ", pageClass=" + pageClass +
                ", uri='" + uri + '\'' +
                '}';
    }
}
